package com.zy.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.business.domain.TbReportUser;
import com.zy.business.mapper.ReportUserMapper;
import com.zy.business.service.ReportUserService;
import com.zy.common.core.domain.AjaxResult;
import com.zy.common.utils.SecurityUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @description: 工作汇报实现类
 * @author: whf
 * @create: 2023-02-23 16:48
 **/
@Service
public class ReportUserServiceImpl extends ServiceImpl<ReportUserMapper, TbReportUser> implements ReportUserService {
    @Override
    public AjaxResult changeView(Long id) {
        TbReportUser reportUser = baseMapper.selectOne(new QueryWrapper<TbReportUser>().eq("report_id",id).eq("user_id", SecurityUtils.getUserId()));
        reportUser.setIsRead(1);
        reportUser.setUpdateTime(new Date());
        baseMapper.updateById(reportUser);
        return AjaxResult.success();
    }

    @Override
    public AjaxResult getReadList(Long id) {
        List<TbReportUser> ReportUser = baseMapper.getReadList(id);
        return AjaxResult.success(ReportUser);
    }
}
